<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
	xmlns:f="livcos.org/ns/xslt/function"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:doc="livcos.org/ns/doc"
	exclude-result-prefixes="doc f">

  <xsl:import href="document.xsl"/>
  
  <xsl:template match="doc:document/doc:body">
    <body>
      <div id="{f:object-id(.)}" class="contentPanel">
        <div class="content">
          <table>
            <tbody>
              <tr>
                <td>
                  <xsl:apply-templates select="doc:image[1]"/>
                </td>
                <td>
                  <xsl:apply-templates select="doc:paragraph[@id != 'paragraph_2']"/>
                </td>
              </tr>
            </tbody>
          </table>
        	<table class="blocks">
            <tbody>
              <tr>
                <td width="50%" class="left">
                  <xsl:apply-templates select="doc:chapter[position() &lt; 3]"/>
                </td>
                <td width="50%" class="right">
                  <xsl:apply-templates select="doc:chapter[position() &gt; 2]"/>
                </td>
              </tr>
            </tbody>
          </table>
          <xsl:apply-templates select="doc:paragraph[@id = 'paragraph_2']" mode="footer"/>
        </div>
      </div>
    </body>
  </xsl:template>
  
  <xsl:template name="page_head_extension">
    <link href="{f:caller-uri(resolve-uri('css/intro.css'))}" rel="stylesheet" type="text/css"/>
  </xsl:template>
  
  <xsl:template match="doc:chapter">
    <div id="{@id}">
      <xsl:element name="h{count(ancestor::doc:chapter)+1}">
        <xsl:apply-templates select="doc:title/node()"/>
      </xsl:element>
      <xsl:apply-templates select="*[name(.)!='title']"/>
    </div>
  </xsl:template>

  <xsl:template match="doc:paragraph" mode="footer">
    <p id="{@id}" style="text-align:right; font-size: 80%;">
      <xsl:apply-templates select="node()"/>
    </p>
  </xsl:template>
  
</xsl:stylesheet>